/shell/src/test/java/org/jboss/forge/shell/test/resources/MockResourceInjectionPlugin.java

https://github.com/cunningt/core-1 · Java · 111 lines · 68 code · 19 blank · 24 comment · 0 complexity · a9a01e1e72bba9fde752494f48beacf3 MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2010, Red Hat, Inc., and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.jboss.forge.shell.test.resources;
  23. import javax.enterprise.event.Observes;
  24. import javax.inject.Inject;
  25. import javax.inject.Singleton;
  26. import org.jboss.forge.resources.DirectoryResource;
  27. import org.jboss.forge.resources.Resource;
  28. import org.jboss.forge.resources.java.JavaResource;
  29. import org.jboss.forge.shell.plugins.Alias;
  30. import org.jboss.forge.shell.plugins.Current;
  31. import org.jboss.forge.shell.plugins.DefaultCommand;
  32. import org.jboss.forge.shell.plugins.Plugin;
  33. import org.jboss.forge.shell.plugins.RequiresResource;
  34. /**
  35. * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
  36. */
  37. @Alias("inject")
  38. @Singleton
  39. @RequiresResource(DirectoryResource.class)
  40. public class MockResourceInjectionPlugin implements Plugin
  41. {
  42. @Inject
  43. @Current
  44. private Resource<?> r;
  45. @Inject
  46. @Current
  47. private JavaResource j;
  48. @Inject
  49. @Current
  50. private DirectoryResource d;
  51. private Resource<?> observedResource;
  52. @DefaultCommand
  53. public void run()
  54. {
  55. }
  56. public void observe(@Observes final MockEvent event, @Current final Resource<?> resource)
  57. {
  58. this.observedResource = resource;
  59. }
  60. public Resource<?> getR()
  61. {
  62. return r;
  63. }
  64. public void setR(final Resource<?> r)
  65. {
  66. this.r = r;
  67. }
  68. public JavaResource getJ()
  69. {
  70. return j;
  71. }
  72. public void setJ(final JavaResource j)
  73. {
  74. this.j = j;
  75. }
  76. public DirectoryResource getD()
  77. {
  78. return d;
  79. }
  80. public void setD(final DirectoryResource d)
  81. {
  82. this.d = d;
  83. }
  84. public Resource<?> getObservedResource()
  85. {
  86. return observedResource;
  87. }
  88. public void setObservedResource(final Resource<?> observedResource)
  89. {
  90. this.observedResource = observedResource;
  91. }
  92. }