Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.kasource.kaevent.channel;
 
 
 import  com.google.inject.ConfigurationException;
 import  com.google.inject.CreationException;
 import  com.google.inject.Inject;
import  com.google.inject.Injector;
import  com.google.inject.ProvisionException;
import  com.google.inject.Singleton;

Guice Channel Factory. Will allow channel instances to be created via Guice.

Author(s):
rikardwi
@Singleton
public class GuiceChannelFactory extends ChannelFactoryImpl {
	@Inject
	private Injector injector;

Constructor.

Parameters:
channelRegister Channel Register.
eventRegister Event Register
eventMethodInvoker Event Method Invoker.
beanResolver Bean Resolver.
	@Inject
	public GuiceChannelFactory(ChannelRegister channelRegister,
			EventRegister eventRegisterEventMethodInvoker eventMethodInvoker,
			BeanResolver beanResolver) {
		super(channelRegistereventRegistereventMethodInvokerbeanResolver);
	}

Returns a new Channel instance.

Parameters:
channelClass Class to instance of.
name Name of the channel.
Returns:
new Channel instance.
Throws:
IllegalStateException if a channel with name already created or channelClass could not be instancieated.
     protected Channel getNewChannel(Class<? extends ChannelchannelClass,
				String namethrows IllegalStateException {
    	 if (channelClass.equals(ChannelImpl.class)) {
    		 return super.getNewChannel(channelClassname);
    	 }
    	 try {
    		 	 
    		 Channel channel = .getInstance(channelClass);
    		 channel.setName(name);
    		 return channel;
    	 } catch (ConfigurationException ce) {
    	     return super.getNewChannel(channelClassname);
    	 } catch (ProvisionException pe) {
    	     return super.getNewChannel(channelClassname);
    	 } catch (CreationException ce) {
    	     return super.getNewChannel(channelClassname);
    	 }
    	 
	 }
New to GrepCode? Check out our FAQ X